using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using HuiLian.Common.Input;
using HuiLian.Common.Output;
using HuiLian.Model.Platform;
using HuiLian.Service.Platform.PipeHealth;
using HuiLian.Service.Platform.PipeHealth.Input;
using Org.BouncyCastle.Crypto;

namespace HuiLian.Web.Controllers.Platform
{
    /// <summary>
    /// 管段健康管理
    /// </summary>
    public class PipeHealthController : AreaController
    {
        private readonly IPipeHealthService _pipeHealthServices;

        public PipeHealthController(IPipeHealthService pipeHealthServices)
        {
            _pipeHealthServices = pipeHealthServices;
        }

        /// <summary>
        /// 查询单条管段健康
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _pipeHealthServices.GetAsync(id);
        }

        /// <summary>
        /// 查询分页管段健康
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<PipeHealthEntity> model)
        {
            return await _pipeHealthServices.PageAsync(model);
        }

        /// <summary>
        /// 新增管段健康
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(PipeHealthAddInput input)
        {
            return await _pipeHealthServices.AddAsync(input);
        }

        /// <summary>
        /// 修改管段健康
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(PipeHealthUpdateInput input)
        {
            return await _pipeHealthServices.UpdateAsync(input);
        }

        /// <summary>
        /// 删除管段健康
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _pipeHealthServices.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除管段健康
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _pipeHealthServices.BatchSoftDeleteAsync(ids);
        }

        /// <summary>
        /// 管线状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> PipelineStatus(PageInput<PipelineStatusInput> model)
        {
            return await _pipeHealthServices.PipelineStatus(model);
        }

        /// <summary>
        /// 健康报告
        /// </summary>
        /// <param name="管段编号"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> HealthReport(string 管段编号)
        {
            return await _pipeHealthServices.HealthReport(管段编号);
        }
    }
}
